package com.gang.mars.basic.iterable.demo0;

import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.function.Consumer;

/**
 * @author gang.chen
 * @description
 * @Date 2021/7/8 14:13
 */
public class DemoTest {
    public static void main(String[] args) {
        MyAnnotationMetadata metadata = new MyAnnotationMetadataImpl(Cls1.class);
        MyIterable iterable = new MyIterableImpl(Cls1.class,Cls1.class);
        System.out.println(iterable);
    }

    /**
     * 对象的层级关于
     * 1，BeanDefinition     Bean定义对象
     * 2，AnnotationMetadata Metadata 元数据对象
     * 3，Iterable           Iterable迭代口对象
     * 4，Annotation         Annotation注解对象
     * */

    public class Cls1{
        String name= "gang.chen";
    }

    /**
     * 注解元数据接口
     * */
    public interface MyAnnotationMetadata{

    }
    /**
     * 注解元数据接口实现类
     * */
    public static class MyAnnotationMetadataImpl implements MyAnnotationMetadata{
        final Class<?> aClass;
        public MyAnnotationMetadataImpl(Class<?> aClass){
            this.aClass = aClass;
        }

    }


    /**
     * 泛型接口
     * 传入泛型可以为，任意继承自Annotation的注解类
     * */
    public interface MyAnnotation<A extends Annotation>{
    }

    /**
     * 泛型接口实现
     * */
    public class MyAnnotationImpl<A extends Annotation> implements MyAnnotation<A> {
    }


    /**
     * 迭代器接口
     * */
    public interface MyIterable extends Iterable<MyAnnotation<Annotation>>{
    }
    /**
     * 迭代器实现类
     * */
    public static class MyIterableImpl implements MyIterable {
        private final Object source;
        private final AnnotatedElement element;

        public MyIterableImpl(Object source, AnnotatedElement element) {
            this.source = source;
            this.element = element;
        }

        /**
         * 业务意义，
         * */
        @Override
        public Iterator<MyAnnotation<Annotation>> iterator() {
            return null;
        }

        @Override
        public void forEach(Consumer<? super MyAnnotation<Annotation>> action) {

        }

        @Override
        public Spliterator<MyAnnotation<Annotation>> spliterator() {
            return null;
        }


    }

}
